<%@ page language="java" import="org.json.*,java.sql.*,com.microsoft.sqlserver.jdbc.*,java.io.*,web.rec.*" 
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"  %>

<% 
	Connection conn = ResourceTool.getConnection();
	String section_id = request.getParameter("section_id");
	try {
	// Create the prepared statement and use it to
	// INSERT the student attrs INTO the Student table.
	Statement stmt = conn.createStatement();
	ResultSet rs = stmt.executeQuery("SELECT course_num, title from Class,Section where "
			+ "class.class_id = section.class_id and "
			+ "section.section_id = '"+ section_id + "'" );
	if ( rs.next()) { // found send JSON string with employee details to client
	    out.println("{\"title\":");
	    out.println("\"" + rs.getString("title") + "\"");
	    out.println(",\"course_num\":");
	    out.println("\"" + rs.getString("course_num") + "\"");
	    out.println("}");
	 }
	 else {  // not found send JSON string with error message
	     out.println("{\"error\":\"section id not found!\"}");
	 }
	// Close the ResultSet
	rs.close();
	// Close the Statement
	stmt.close();
	} catch (SQLException sqle) {
		out.println(sqle.getMessage());
	} catch (Exception e) {
		out.println(e.getMessage());
	}
	%>